package com.itic.mall.system.malltoken.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.itic.appbase.framework.common.service.CrudService;
import com.itic.mall.system.malltoken.persistence.dao.MallTokenDao;
import com.itic.mall.system.malltoken.persistence.model.MallToken;
import com.itic.mall.system.malltoken.persistence.model.MallTokenExample;
import com.itic.mall.system.user.persistence.dao.MallUserDao;
import com.itic.mall.system.user.persistence.model.MallUser;


@Service
@Transactional
public class MallTokenService
     extends CrudService<MallTokenDao,MallToken,MallTokenExample> {
    @Autowired
    private MallTokenDao mallTokenDao;
    @Autowired
    private MallUserDao mallUserDao;

    public String addTokenAndRegUser( MallToken createToken, MallUser user ){
    	mallUserDao.insert(user);
    	mallTokenDao.insert(createToken);
    	return SUCCESS;
    }

	public MallToken getMallTokenByToken(String token) {
		return mallTokenDao.getMallTokenByToken(token);
	}

	public void deleteTrueByExample(MallTokenExample example) {
		mallTokenDao.deleteByExample(example);
	}
}